﻿/// Write a program that downloads a file from Internet (e.g. http://www.devbg.org/img/Logo-BASD.jpg) 
/// and stores it the current directory. Find in Google how to download files in C#.
/// Be sure to catch all exceptions and to free any used resources in the finally block.


﻿using System;
using System.Net;


namespace c_sh_II_lek_5_exeptions
{
    class zad2
    {
        static void Main()
        {
            using (WebClient webClient = new WebClient())
            {
                try
                {
                    webClient.DownloadFile("http://www.devbg.org/img/Logo-BASD.jpg", "../../logo-BASD.jpg");// bin/debug
                }

                catch (WebException)
                {
                    Console.Error.WriteLine("Invalid address or empty file!");
                }

                catch (NotSupportedException)
                {
                    Console.Error.WriteLine("The method does not support simultaneous downloads!");
                }
            }
        }
    }
}
